import {Component} from 'react';
import {Select} from 'antd';


let trustyTool  = require('../../tools/trusty-tool');


const mapStateToProps = (state) => {

}


const mapDispatchToProps = (dispatch) => {

  return {
    onDidMount:() => {
      dispatch({
        type:'trusty/queryTrusty';
      });
    }
  }
}


class TrustySelect extends Component{


  componentDidMount(){
    // this.props.onDidMount();
    console.log('trusty did mount');
  }

  render(){
    const  projectId  = this.props.project;

    let options  = [];
    let defaultValue = [];

    const trustyLib  = trustyTool.getTrustyLibrary();
    for(let i =0; i < trustyLib.length; i++){
      let info  = trustyLib[i];
      options.push(
        <Select.Option key={info.userId} > {info.nickName} </Select.Option>
      );
    }

    const trustyIdList  = trustyTool.getTrustyListOfProject(projectId);
    if( trustyIdList && trustyIdList.length ){
        for(let id of trustyList){
          defaultValue.push(id.toString());
        }
    }

    return(
      <Select
        style={{'width':160}}
        mode='multiple'
        size='small'
        placeholder='点击选择'
        defaultValue={defaultValue}

        >
        {options}
      </Select>
    )
  }
}
